<script type="text/javascript" src="<?=PATH_URL.'static/js/admin/jquery.slugit.js'?>"></script>
<script type="text/javascript">
$(document).ready( function() {
	$("#titleViAdmincp").slugIt({
		events: 'keyup blur',
		output: '#slugAdmincp',
		space: '-'
	});
});

function save(){
	var options = {
		beforeSubmit:  showRequest,  // pre-submit callback
		success:       showResponse  // post-submit callback
    };
  $('#descVnAdmincp').val(oEdit1.getHTMLBody());
	$('#descEnAdmincp').val(oEdit2.getHTMLBody());
	$('#descGrAdmincp').val(oEdit3.getHTMLBody());
	$('#frmManagement').ajaxSubmit(options);
}

function showRequest(formData, jqForm, options) {
	var form = jqForm[0];
	if(form.titleViAdmincp.value == ''){
		$('#txt_error').html('Please enter information!!!');
		$('#loader').fadeOut(300);
		show_perm_denied();
		return false;
	}
}

function showResponse(responseText, statusText, xhr, $form) {
	if(responseText=='success'){
		location.href=root+"admincp/"+module+"/#/save";
	}

	if(responseText=='error-title-exists'){
		$('#txt_error').html('Title already exists!!!');
		$('#loader').fadeOut(300);
		show_perm_denied();
		$('#titleViAdmincp').focus();
		return false;
	}

	if(responseText=='error-slug-exists'){
		$('#txt_error').html('Slug already exists!!!');
		$('#loader').fadeOut(300);
		show_perm_denied();
		$('#slugAdmincp').focus();
		return false;
	}

	if(responseText == 'same_parent'){
		$('#txt_error').html('Cannot set parrent to itself!!!');
		$('#loader').fadeOut(300);
		show_perm_denied();
		$('#slugAdmincp').focus();
		return false;
	}

	if(responseText=='permission-denied'){
		show_perm_denied();
	}
}
</script>
<div class="gr_perm_error" style="display:none;">
	<p><strong>FAILURE: </strong><span id="txt_error">Permission Denied.</span></p>
</div>
<div class="table">
	<div class="head_table"><div class="head_title_edit"><?=$module?></div></div>
	<div class="clearAll"></div>

	<form id="frmManagement" action="<?=PATH_URL.'admincp/'.$module.'/save/'?>" method="post" enctype="multipart/form-data">
	<input type="hidden" value="<?=$id?>" name="hiddenIdAdmincp" />
	<div class="row_text_field_first">
		<table cellspacing="0" cellpadding="0" border="0" width="100%">
			<tr>
				<td class="left_text_field">Status:</td>
				<td class="right_text_field"><input <?php if(isset($result->status)){ if($result->status==1){ ?>checked="checked"<?php }}else{ ?>checked="checked"<?php } ?> type="checkbox" class="custom_chk" name="statusAdmincp" /></td>
			</tr>
		</table>
	</div>

	<div class="row_text_field">
		<table cellspacing="0" cellpadding="0" border="0" width="100%">
			<tr>
				<td class="left_text_field">Order view:</td>
				<td class="right_text_field"><input value="<?php if(isset($result->order_view)) { print $result->order_view; }else{ print '';} ?>" type="text" name="orderViewGrAdmincp" id="orderViewGrAdmincp" /></td>
			</tr>
		</table>
	</div>

	<div class="row_text_field">
		<table cellspacing="0" cellpadding="0" border="0" width="100%">
			<tr>
				<td class="left_text_field">Parrent:</td>
				<td class="right_text_field">
					<?php if(isset($options)) : ?>
						<select name='parentIdAdmincp'>
							<option value='0'>[ Menu ]</option>
							<?php echo $options; ?>
						</select>
					<?php endif; ?>
				</td>
			</tr>
		</table>
	</div>

	<div class="row_text_field">
		<table cellspacing="0" cellpadding="0" border="0" width="100%">
			<tr>
				<td class="left_text_field">Name VI:</td>
				<td class="right_text_field"><input value="<?php if(isset($result->title_vi)) { print $result->title_vi; }else{ print '';} ?>" type="text" name="titleViAdmincp" id="titleViAdmincp" /></td>
			</tr>
		</table>
	</div>

	<div class="row_text_field">
		<table cellspacing="0" cellpadding="0" border="0" width="100%">
			<tr>
				<td class="left_text_field">Name EN:</td>
				<td class="right_text_field"><input value="<?php if(isset($result->title_en)) { print $result->title_en; }else{ print '';} ?>" type="text" name="titleEnAdmincp" id="titleEnAdmincp" /></td>
			</tr>
		</table>
	</div>

	<div class="row_text_field">
		<table cellspacing="0" cellpadding="0" border="0" width="100%">
			<tr>
				<td class="left_text_field">Name GERMAN:</td>
				<td class="right_text_field"><input value="<?php if(isset($result->title_gr)) { print $result->title_gr; }else{ print '';} ?>" type="text" name="titleGrAdmincp" id="titleGrAdmincp" /></td>
			</tr>
		</table>
	</div>

	<div class="row_text_field">
		<table cellspacing="0" cellpadding="0" border="0" width="100%">
			<tr>
				<td class="left_text_field">Slug:</td>
				<td class="right_text_field"><input value="<?php if(isset($result->slug)) { print $result->slug; }else{ print '';} ?>" type="text" name="slugAdmincp" id="slugAdmincp" /></td>
			</tr>
		</table>
	</div>

	<div class="row_text_field">
		<table cellspacing="0" cellpadding="0" border="0" width="100%">
			<tr>
				<td class="left_text_field">Description VI:</td>
				<td class="right_text_field">
					<textarea name="descVnAdmincp" id="descVnAdmincp" cols="" rows="8"><?php if(isset($result->description_vi)) { print $result->description_vi; }else{ print '';} ?></textarea>
					<script type="text/javascript">
						var oEdit1 = new InnovaEditor("oEdit1");
						oEdit1.width = "100%";
						oEdit1.cmdAssetManager="modalDialogShow('"+root+"static/editor/assetmanager/assetmanager.php',640,445);";
						oEdit1.REPLACE("descVnAdmincp");
					</script>
				</td>
			</tr>
		</table>
	</div>

	<div class="row_text_field">
		<table cellspacing="0" cellpadding="0" border="0" width="100%">
			<tr>
				<td class="left_text_field">Description EN:</td>
				<td class="right_text_field">
					<textarea name="descEnAdmincp" id="descEnAdmincp" cols="" rows="8"><?php if(isset($result->description_en)) { print $result->description_en; }else{ print '';} ?></textarea>
					<script type="text/javascript">
						var oEdit2 = new InnovaEditor("oEdit2");
						oEdit2.width = "100%";
						oEdit2.cmdAssetManager="modalDialogShow('"+root+"static/editor/assetmanager/assetmanager.php',640,445);";
						oEdit2.REPLACE("descEnAdmincp");
					</script>
				</td>
			</tr>
		</table>
	</div>

	<div class="row_text_field">
		<table cellspacing="0" cellpadding="0" border="0" width="100%">
			<tr>
				<td class="left_text_field">Description GERMAN:</td>
				<td class="right_text_field">
					<textarea name="descGrAdmincp" id="descGrAdmincp" cols="" rows="8"><?php if(isset($result->description_gr)) { print $result->description_gr; }else{ print '';} ?></textarea>
					<script type="text/javascript">
						var oEdit3 = new InnovaEditor("oEdit3");
						oEdit3.width = "100%";
						oEdit3.cmdAssetManager="modalDialogShow('"+root+"static/editor/assetmanager/assetmanager.php',640,445);";
						oEdit3.REPLACE("descGrAdmincp");
					</script>
				</td>
			</tr>
		</table>
	</div>

	</form>
</div>
